<template>
  <div>
    <div v-for="item in tabs" :key="item.id" v-show="item.show">
      <a-card :bordered="false">
        <redirect func="addFromProcess" :id="item.id" @close="close" @refreshParent="refreshParent"
                  @setTitle="setTitle" :processInstanceName="item.title"></redirect>
      </a-card>
    </div>
  </div>
</template>

<script>

  import Redirect from './Redirect'

  export default {
    name: 'RedirectAddTab',
    components: {
      Redirect
    },
    props: {
      id: String,
    },
    data () {
      return {
        tabs: [],
      }
    },
    methods: {
      //关闭页面
      close () {
        // //console.log("close");
      },
      //刷新父页面
      refreshParent () {
        // //console.log("refreshParent");
      },
      //设置标题
      setTitle (title) {
        const tab = this.tabs.find(vo => vo.id == this.id)
        if (tab) {
          tab.title = title
        }
        // this.dynamicRouterShow(this.$route.fullPath, title)
      },
      reLoad () {
        if (this.id) {
          this.tabs = [{
            id: this.id,
            show: true,
            title: this.$t('m.bpm.common.bpmPage')
          }]
        } else {
          this.tabs = []
        }
      }
    },
    watch: {
      id: {
        handler (value) {
          this.reLoad()
        },
        immediate: true
      }
    }
  }
</script>
